import request from "@/utils/request";

// 获取商品分类列表
export function getCategoryList() {
  return request({
    url: "/shop/category/list",
    method: "get",
  });
}

// 新增商品分类
export function createCategory(data) {
  return request({
    url: "/shop/category/create",
    method: "post",
    data,
  });
}

// 更新商品分类
export function updateCategory(data) {
  return request({
    url: "/shop/category/update",
    method: "put",
    data,
  });
}

// 删除商品分类
export function deleteCategory(id) {
  return request({
    url: `/shop/category/delete/${id}`,
    method: "delete",
  });
}

// 获取商品列表
export function getProductList(params) {
  return request({
    url: "/shop/product/list",
    method: "get",
    params,
  });
}

// 新增商品
export function createProduct(data) {
  return request({
    url: "/shop/product/create",
    method: "post",
    data,
  });
}

// 更新商品
export function updateProduct(data) {
  return request({
    url: "/shop/product/update",
    method: "put",
    data,
  });
}

// 删除商品
export function deleteProduct(id) {
  return request({
    url: `/shop/product/delete/${id}`,
    method: "delete",
  });
}

// 获取订单列表
export function getOrderList(params) {
  return request({
    url: "/shop/order/list",
    method: "get",
    params,
  });
}

// 更新订单状态
export function updateOrderStatus(data) {
  return request({
    url: "/shop/order/updateStatus",
    method: "put",
    data,
  });
}

// 上传图片
export function uploadImage(data) {
  return request({
    url: "/upload/image",
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
